from PIL import Image
 
import pytesseract
def banarzing(img,threshold):
    pixdata=img.load()
    w,h=img.size#if not tuple is not callable
    for y in range(h):
        for x in range(w):
            if pixdata[x,y]<threshold:
                pixdata[x,y]=90
            # else:
            #     pixdata[x,y]=230
    return img
# im.show()
im=Image.open(r'F:\iPhone4照片\2015_11/IMG_1185.JPG')
im=im.convert('L')
img1=banarzing(im,60)
img1.show()
text=pytesseract.image_to_string(img1,lang='chi_sim')
text=text.replace(' ','')
print(text)# img1.show()